<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- Bootstrap -->
	<link href="css/bootstrap.min.css" rel="stylesheet">

	<%@ page language="java" contentType="text/html; charset=UTF-8"
			 pageEncoding="UTF-8"%>
	<%
		String res="";

		String state=request.getParameter("state");

		if(state==null||state.equals("")){
			state="-1";
			res="other";
		}
		if(state.equals("1")){
			res="ok";
		}else if(state.equals("0")){
			res="error";
		}
	%>
<title>Insert title here</title>

	<script>
		function checkform() {

			var name=document.getElementById("username").value;
			var psw=document.getElementById("input").value;
			if(name.length<1){
                alert("用户名不能为空")
                return false;
            }
            if(psw.length<1){
                alert("文本不能为空")
                return false;
            }
        }

        function selectchange(name) {
            document.getElementById("d1").setAttribute("hidden","hidden");
            document.getElementById("d2").setAttribute("hidden","hidden");
		    if(name=="text"){
		        document.getElementById("d1").removeAttribute("hidden");
			}else if(name="image"){
                document.getElementById("d2").removeAttribute("hidden");
			}
			console.log("s1:"+name);
        }
	</script>
</head>
<body >
<%--http://localhost:8080/firsth5/msg/addmsg.jsp--%>
<div class="container">
<form action="../../servlet/LoginServlet" onsubmit="return checkform()"  class="form-signin">
	<select id="select1" onchange="selectchange(this.value)">
		<option name="text" >text</option>
		<option name="image" >image</option>
		<option name="voice">voice</option>
		<option name="video">video</option>
		<option name="red_packet">红包</option>
		<option name="link">link</option>
	</select>
	<div id="d1">
	<div>
	<label  class="sr-only">用户名</label>
	<input placeholder="输入用户名" name="username" id="username"   class="form-control">
	</div>
	<div>
	<label>输入文本</label>
	<input placeholder="输入文本" id="input" name="input" id="input">

	</div>
	</div>
	<div hidden="hidden" id="d2">
		<div>
			<label>用户名</label>
			<input placeholder="输入用户名" name="username" id="username1">
		</div>
		<div>
			<label>输入时长</label>
			<input placeholder="输入时长" id="duration" name="input" id="duration">
		</div>
	</div>
	<input type="submit" >
</form>
	<p>
		结果是:<%=res %>
	</p>
</div>
</body>
</html>